package com.cc.secondKill.rabbit;

import com.cc.secondKill.commnons.JsonUtils;
import com.cc.secondKill.pojo.MiaoshaMessage;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.amqp.core.AmqpTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service
public class MQSender {

    @Autowired
    private AmqpTemplate amqpTemplate;

    private static Logger logger = LoggerFactory.getLogger(MQSender.class);

    public void sendMiaoshaMessage(MiaoshaMessage message){
        String msg = JsonUtils.obj2String(message);
        logger.info("Send Message::{}",msg);
        amqpTemplate.convertAndSend("queueTestKey",msg);
    }
}
